package com.hospital.ui.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hospital.ui.widget.BasePageLayout;

public class PageCache {

	private Map<String, BasePageLayout> mPageCache;

	private List<String> mPageHistoryList;

	private int mMaxSize;

	public PageCache(int maxSize) {
		mPageCache = new HashMap<String, BasePageLayout>();
		mPageHistoryList = new ArrayList<String>();
		mMaxSize = maxSize;
	}

	public void setPageCacheSize(int maxSize) {
		mMaxSize = maxSize;
	}

	public BasePageLayout getPage(String key) {
		if (mPageCache != null) {
			if (mPageCache.containsKey(key)) {
				return mPageCache.get(key);
			}
		}
		return null;
	}

	public void addPage(String key, BasePageLayout page) {
		if (mPageCache != null) {
			if (!mPageCache.containsKey(key)) {
				mPageCache.put(key, page);
			}
		}
	}
}
